package com.neusoft.controller;

import com.neusoft.po.CommonResult;
import com.neusoft.po.Redenv;
import com.neusoft.service.RedenvService;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/RedenvController")
@RefreshScope
public class RedenvController {

    @Autowired
    private RedenvService redenvService;

    @RequestMapping(value="saveOneRedenvByUserId",method = RequestMethod.POST )
    public CommonResult<Integer> saveOneRedenvByUserId(@RequestBody Redenv redenv){
        return new CommonResult(200,"success", redenvService.saveOneRedenvByUserId(redenv));
    }

    //List
    @RequestMapping(value="getAllRedenvsByUserId",method = RequestMethod.GET)
    public CommonResult<List> getAllRedenvsByUserId(@RequestParam String userId){
        return new CommonResult(200,"success", redenvService.getAllRedenvsByUserId(userId));
    }

    @RequestMapping(value="getRedenvByRedenvId",method = RequestMethod.GET)
    public CommonResult<Redenv> getRedenvByRedenvId(@RequestParam Integer redenvId){
        return new CommonResult(200,"success", redenvService.getRedenvByRedenvId(redenvId));
    }

    @RequestMapping(value="useRedenvByRedenvId",method = RequestMethod.PUT)
    public CommonResult<Integer> useRedenvByRedenvId(@RequestParam Integer redenvId){
        return new CommonResult(200,"success", redenvService.useRedenvByRedenvId(redenvId));
    }


}
